<template>
  <div class="warp">
    <div class="cantanier">
      <div class="middle">
        <div class="middle-CD">热门新碟</div>

        <ul>
          <div class="dists">
            <li class="dist" v-for="al in albumn1">
              <div class="list">
                <a title="Live Tody">
                  <div class="imglist">
                    <img class="Cover" :src="al.picUrl" />
                    <div class="fonts">
                      <span class="iconfont icon-bofang1"></span>
                    </div>
                  </div>
                </a>
                <a title="Live Tody">
                  <p class="dist-title">{{ al.name }}</p>
                </a>
                <span class="nickNmae" v-if="al.artists">{{
                  al.artists.map((i) => i?.name).join('/')
                }}</span>
              </div>
            </li>
          </div>
        </ul>
        <div class="titles">
          <h3>全部新碟</h3>
          <div class="listtitle">
            <span>全部</span><i>|</i><span>华语</span><i>|</i> <span>欧美</span
            ><i>|</i><span>韩国</span><i>|</i><span>日本</span>
          </div>
        </div>
        <ul>
          <div class="dists">
            <li class="dist" v-for="al in albumn">
              <div class="list">
                <a title="Live Tody">
                  <div class="imglist">
                    <img :src="al.picUrl" />
                    <div class="fonts">
                      <span class="iconfont icon-bofang1"></span>
                    </div>
                  </div>
                </a>
                <a title="Live Tody">
                  <p class="dist-title">{{ al.name }}</p>
                </a>
                <span class="nickNmae" v-if="al.artists">{{
                  al.artists.map((i) => i?.name).join('/')
                }}</span>
              </div>
            </li>
          </div>
        </ul>
      </div>
      <el-pagination
        v-if="albumn"
        v-model:currentPage="curPage"
        layout=" prev, pager, next"
        :total="299"
        @size-change="handleSizeChange"
        @current-change="handleCurrentChange"
      />
    </div>
  </div>
</template>

<script lang="ts" setup>
import { album } from '@/api/model/album'
import { singerMessage } from '@/api/model/singer'
import { reqAlbumApi } from '@/api/recommend'
import { ref, onMounted } from 'vue'
const albumn = ref<album[]>()
const albumn1 = ref<album[]>()
const curPage = ref(1)
const pageSize = ref(35)

const handleSizeChange = (val: number) => {
  console.log(`${val} items per page`)
}
const handleCurrentChange = async (val: number) => {
  const { albums } = await reqAlbumApi('hot', 35, (val - 1) * 35 + 10)
  albumn.value = albums
}
onMounted(async () => {
  const result = await reqAlbumApi('hot', 35, (curPage.value - 1) * 35 + 10)
  const result1 = await reqAlbumApi('new', 10)
  albumn1.value = result1.albums

  albumn.value = result.albums

  console.log(result)
})
</script>

<style scoped>
.warp {
  width: 100%;
  height: 100%;
  background-color: #f5f5f5;
}
.cantanier {
  margin: 0 auto;
  width: 980px;
  height: 100%;
  background-color: #ffffff;
}
.middle {
  padding: 40px;
}
.middle-CD {
  height: 40px;
  font-size: 24px;
  border-bottom: 2px solid #c20c0c;
}
.list {
  background: url(https://s2.music.126.net/style/web2/img/coverall.png?e1d4eb93e51aacf9809854448e0f446c)
    no-repeat;
  width: 153px;
  height: 130px;
  background-position: 0 -845px;
}
.dist {
  width: 183px;
  height: 208px;
  padding: 0 33px 30px 0;
  cursor: pointer;
}
ul {
  margin-top: 20px;
}
.dists {
  width: 960px;
  display: flex;
  flex-wrap: wrap;
}

.dist img {
  width: 130px;
  height: 130px;
}
.fonts {
  position: absolute;
  left: 95px;
  top: 95px;
  display: none;
}
.imglist {
  position: relative;
}
.imglist:hover .fonts {
  display: block;
}
.icon-bofang1 {
  display: inline-block;
  font-size: 28px;
  color: #e0e0df;
}
.dist-title {
  margin: 8px 0 3px 0;
  height: 20.5px;
  font-size: 14px;
  color: #000;
}
.dist-title:hover {
  text-decoration: underline;
}
.nickNmae {
  font-size: 12px;
}
.titles {
  width: 100%;
  height: 40px;
  display: flex;
  border-bottom: 2px solid #c20c0c;
}
.listtitle {
  width: 226px;
  height: 16px;
  display: flex;
  align-items: center;
  color: #666;
  margin-left: 20px;
  margin-top: 12px;
  cursor: pointer;
}
.listtitle:hover {
  text-decoration: underline;
}
.titles h3 {
  font-size: 24px;
}
.listtitle span {
  font-size: 12px;
}
.listtitle i {
  font-size: 12px;
  margin: 0 10px 0 10px;
  color: #c7c7c7;
}
</style>
<style></style>
